#ifndef __BUS_ARGS_H
#define __BUS_ARGS_H

#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>

#include "data.h"

typedef struct
{
	char *arg;
	char a;
	char *val;
	int flagged;

	char *desc;
	char **examples;
} z_arg;

typedef struct
{
	char *name;
	char *version;
	char *author;
	int year;

	char *usage;

	z_arg *buf;
	z_size head;
	z_size size;
} z_arg_buffer;

z_arg_buffer z_arg_buffer_init(z_size s, char *u);
int z_arg_buffer_release(z_arg_buffer ab);
int z_arg_buffer_sign(z_arg_buffer *ab, char *n, char *v, char *a, int y);
int z_arg_buffer_append(z_arg_buffer *ab, char *arg);
int z_arg_buffer_append_with_shorthand(z_arg_buffer *ab, char *arg, char a);
z_size z_arg_buffer_find(z_arg_buffer *ab, char *arg);
int z_arg_buffer_describe(z_arg_buffer *ab, char *arg, char *desc);
int z_arg_buffer_example(z_arg_buffer *ab, char *arg, ...);
int z_arg_buffer_flag_get(z_arg_buffer *ab, char *arg);
int z_arg_buffer_flag_set(z_arg_buffer *ab, char *arg, int f);
char *z_arg_buffer_value_get(z_arg_buffer *ab, char *arg);
char *z_arg_buffer_value_set(z_arg_buffer *ab, char *arg, char *v);
int z_arg_buffer_dump(z_arg_buffer *ab);

int z_init_args(z_arg_buffer *ab, int argc, char *argv[]);

#endif
